package com.usooft.metaTalent.admin.base.service;

import com.usooft.metaTalent.core.system.query.EmployeeQuery;
import com.usooft.metaTalent.core.system.service.EmployeeService;
import com.usooft.metaTalent.core.system.wrapper.EmployeeWrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class BasicSetupService implements SetupService {

    private final EmployeeService employeeService;

    public BasicSetupService(EmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    @Override
    @Transactional
    public void setup() {
        // 员工
        List<EmployeeWrapper> employeeWrapperList = employeeService.list(EmployeeQuery.builder()
                .filter(EmployeeQuery.Filter.builder()
                        .adminIs(Boolean.TRUE)
                        .build())
                .build());
        if (CollectionUtils.isEmpty(employeeWrapperList)) {
            employeeService.createAdmin("管理员", "12345678901", "123456");
        }
    }

}
